import 'package:flutter/material.dart';

class JKDashedLine extends StatelessWidget {
  /* 虚线的方向 */
  final Axis axis;
  /* 每个小虚线的宽度 */
  final double dashedWidth;
  /* 每个小虚线的高度 */
  final double dashedHeight;
  /* 虚线的个数 */
  final int dashedCount;
  /* 虚线的颜色 */
  final Color dashedColor;

  JKDashedLine({
    // 默认是水平的方向
    this.axis = Axis.horizontal,
    this.dashedWidth = 1,
    this.dashedHeight = 1,
    this.dashedCount = 10,
    this.dashedColor = Colors.red
  });

  @override
  Widget build(BuildContext context) {
    return Flex(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        direction: axis,
        children: List.generate(dashedCount, (index) {
          return SizedBox(
              width: dashedWidth,
              height: dashedHeight,
              child: DecoratedBox(
                decoration: BoxDecoration(
                    color: dashedColor
                ),
              )
          );
        })
    );
  }
}

